
/*
 * @Description: 
 * @Author: rendc
 * @Date: 2024-10-14 14:45:22
 * @LastEditors: rendc
 * @LastEditTime: 2024-10-14 15:28:11
 */
/**
 * Test04
 */
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Test04 {

  public static void main(String[] args) throws IOException {
    // 1. 声明流
    // 文件输入流 用于从文件中读取字节数据 FileInputStream
    // FileInputStream(path)
    // 2. 创建流
    InputStream inputStream = new FileInputStream("/Users/cc/Desktop/Java/day32/test.txt");
    System.out.println("InputStream: " + inputStream);
    // 3. 使用流
    byte[] bytes = new byte[10];
    int length = inputStream.read(bytes, 3, 5);// off length
    // length = inputStream.read(bytes);
    System.out.println("length: " + length);
    // System.out.println("bytes =" + bytes);
    // for (int i = 0; i < length; i++) {
    // System.out.println(bytes[i]);
    // }
    for (int i = 0; i < bytes.length; i++) {
      System.out.println(bytes[i]);
    }
    // 4. 关闭流
    inputStream.close();
  }
}